<?php

namespace app\admin\controller;

use think\App;
use think\Request;
use app\admin\services\UserService;
use app\admin\services\AuthentService;
use app\admin\services\IndexService;
use app\admin\services\AdminManuakGroupService;
use think\facade\Session;

class User extends Authent
{
    public function __construct(Request $request = null, App $app = null)
    {
        parent::__construct($request, $app);
        $this->UserService = new UserService();
        $this->indexService = new IndexService();
        $this->AuthentService = new AuthentService;
        $this->AdminManuakGroupService = new AdminManuakGroupService;
        global $authstate;
        if(isset($authstate['status']) && $authstate['status'] !=0 ){
            echo alert_auth("无访问权限!");
            exit();
        }

    }


    /**
     * @return mixed
     * 用户列表
     */
    public function index()
    {
        $loru = $this->AuthentService->lorus();
        $list = $this->UserService->userlist();
        $vers = $this->indexService->Versiond();
        $inty = $this->AdminManuakGroupService->getParentData();
        $this->assign('inty',$inty);
        $this->assign('vers',$vers);
        $this->assign('list',$list['list']);
        $this->assign('loru',$loru);
        return $this->fetch();
    }


    /**
     * @param 添加用户
     */
    public function add(){
        $data = $this->UserService->adduser();
        return json($data);
    }


    /**
     * @param 启用/禁用,用户
     */
    public function jinyong(){
        $data = $this->UserService->examine();
        return json($data);
    }


    /**
     * @param 获取列表数据
     */
    public function bicthmomo(){
        $list = $this->UserService->userlist();
        return json($list);
    }


    /**
     * @param 修改用户
     */
    public function edit(){
        $data = $this->UserService->edit();
        return json($data);
    }


    /**
     * @param 删除用户
     */
    public function del(){
        $data = $this->UserService->delelt();
        return json($data);
    }


    /**
     * @param 分配类型
     */
    public function versio(){
        $data = $this->UserService->versio();
        return json($data);
    }


    /**
     * @param 手册分类
     */
    public function intyer(){
        $data = $this->UserService->intery();
        return json($data);
    }


    /**
     * @param 获取当前分类
     */
    public function vartype(){
        $varac =$this->UserService->verss();
        return json($varac);
    }


    /**
     * @param 获取当手册分类
     */
    public function intsy(){
        $data =$this->UserService->intert();
        return json($data);
    }


}